{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 字符串格式化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "i = 3 ,j = 5 ,i * j=  15\n",
      "i = 3 ,j = 5 ,i * j = 15\n",
      "i = 3 ,j = 5 ,i * j = 15\n",
      "i = 3 ,j = 5 ,i * j = 15\n"
     ]
    }
   ],
   "source": [
    "i = 3\n",
    "j = 5\n",
    "# 方式1 逗号分隔要打印的内容\n",
    "print(\"i =\",i,\",j =\",j, \",i * j= \",i*j)\n",
    "# 方式2\n",
    "print('i = %d ,j = %d ,i * j = %d' % (i, j,i*j))\n",
    "# 方式3\n",
    "print(f\"i = {i} ,j = {j} ,i * j = {i*j}\")\n",
    "# 方式4\n",
    "print(\"i = {} ,j = {} ,i * j = {}\".format(i,j,i*j))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
